function pr=prbq(pls,q1,q2)
    bc=1/gsize;//.38e-23;
    s=1;
    pr=1;
    for i=1:3*gsize-1
        pr2=exp(bc*q1(s,i,pls(i)+2));
        pr4=exp(bc*q2(s,i,pls(i)+2));
        if s==1
            pr3=sum(exp(bc*q1(s,i,2:3)));
            pr5=sum(exp(bc*q2(s,i,2:3)));
        elseif s==gsize
            pr3=sum(exp(bc*q1(s,i,1:2)));
            pr5=sum(exp(bc*q2(s,i,1:2)));
        else
            pr3=sum(exp(bc*q1(s,i,:)));
            pr5=sum(exp(bc*q2(s,i,:)));
        end
        pr=pr*pr2*pr5/(pr3*pr4);
        //printf("%f %f %f %f %f\n",pr,pr2,pr4,pr3,pr5);
        s=s+pls(i);
    end
endfunction
function pr=prbqb(pls,w1,w2,pth1,pth2)
    fr=evalr(pls);
    pr=exp(fr*w1)/exp(fr*w2);
    if pr>1 then
        pr=1;
    end
    pth=atos(pls);
    pr2=exp(sum(pth==pth1))/exp(sum(pth==pth2));
    pr=pr*pr2;
endfunction
function pr=prbqc(pls,w1,w2,pth1,pth2)
    pth=atos(pls);
    pr=exp(sum(pth==pth1))/exp(sum(pth==pth2));
    //pr=pr*pr2;
endfunction
function pr=prbqd(w,wa,epls,pls1,pls2)
    pr=exp(abs(evalr(pls1)-evalr(epls))*w)/exp(abs(evalr(pls2)-evalr(epls))*wa);
endfunction
